import tpl from './index.tpl';
import './index.scss';
import { replaceTpl } from '../../libs/utils';

export default {
    name: 'MoreLoading',
    _tpl(isLoading) {
        return replaceTpl(tpl, {
            isLoading: isLoading ? 'loading' : '',
            text: isLoading ? '正在加载更多' : '没有更多新闻了'
        })
    },
    add(oNewsListWrapper, isLoading) {
        const oMoreLoading = oNewsListWrapper.querySelector('.more-loading');
        oMoreLoading || (oNewsListWrapper.innerHTML += this._tpl(isLoading));
    },
    remove(oNewsListWrapper){
        const oMoreLoading = oNewsListWrapper.querySelector('.more-loading');
        oMoreLoading && oMoreLoading.remove();
    }
}